package d1123.r214.num07;

import java.util.Comparator;
import java.util.SortedSet;
import java.util.TreeSet;

//TreeSet中添加自定义对象
public class Demo04TreeSet {
    public static void main(String[] args){
        TreeSet<Stu> set=new TreeSet<>(new Comparator<Stu>(){
            @Override
            public int compare(Stu o1,Stu o2){
                return Double.compare(o2.getScore(),o1.getScore());
            }
        });
        set.add(new Stu("张三",60,"1001"));
        set.add(new Stu("lisi",80,"1002"));
        set.add(new Stu("wangwu",50,"1003"));
        set.add(new Stu("maliu",98,"1004"));
        set.add(new Stu("qiqi",75,"1005"));
        //System.out.println(set);


        SortedSet<Stu> sset=  set.subSet(new Stu("aa",80,"11"),true,new Stu("bb",60,"5"),true);
        sset.forEach(stu -> System.out.println(stu));
    }
}
